package com.shop.controller;

import java.io.IOException;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@WebFilter("/*")
public class LoginFilter extends HttpFilter{

	@Override
	public void doFilter(HttpServletRequest req, HttpServletResponse res, FilterChain chain)
			throws IOException, ServletException {
		String url=req.getRequestURI();
		if(url.contains("login.jsp") || url.contains("login.do")){
			super.doFilter(req, res, chain);
			return;
		}
		
		if(req.getSession().getAttribute("loginAdmin") != null) {
			super.doFilter(req, res, chain);
		}else {
			res.sendRedirect("login.jsp");
		}
		
	}
}
